###
### Makefile for GNU Interactive Tools
###

###
### Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
###
### This program is  free software; you can  redistribute it and/or modify
### it under the terms  of the GNU General Public  License as published by
### the  Free Software Foundation; either version  2,  or (at your option)
### any later version.
### 
### This program is distributed  in the hope that  it will be  useful, but
### WITHOUT    ANY  WARRANTY;  without   even   the  implied  warranty  of
### MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR   PURPOSE.  See the GNU
### General Public License for more details.
### 
### You should  have received a  copy of  the GNU  General Public  License
### along with   this  program; if   not,  write  to   the Free   Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
###


PRODUCT		= "@PRODUCT@"
VERSION		= "@VERSION@"


srcdir		= @srcdir@
VPATH		= @srcdir@

prefix		= @prefix@
bindir		= $(prefix)/bin
libdir		= $(prefix)/lib/git
termdir		= $(prefix)/lib/git/term

SHELL		= /bin/sh
CFLAGS		= @CFLAGS@
LDFLAGS		= @LDFLAGS@
CPPFLAGS	= @CPPFLAGS@
DEFS		= @DEFS@ -I.. -I$(srcdir)
LIBS		= @LIBS@
CC		= @CC@
CPP		= @CPP@ $(CPPFLAGS) $(DEFS)
INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
HOST		= @HOST@


GIT_OBJS	= @GIT_OBJS@ tty.o window.o inputline.o status.o panel.o git.o\
		  configure.o misc.o signals.o xmalloc.o xstring.o xio.o xid.o\
		  xstack.o system.o fsusage.o\
		  fnmatch.o
GITCMP_OBJS	= gitcmp.o
GITWIPE_OBJS	= gitwipe.o
GITKEYS_OBJS	= gitkeys.o
GITPS_OBJS	= @GITPS_OBJS@ tty.o window.o configure.o misc.o gitps.o\
		  xmalloc.o xstring.o xio.o
GITVIEW_OBJS	= @GITVIEW_OBJS@ tty.o window.o configure.o misc.o gitview.o\
		  xmalloc.o xstring.o xio.o
GIT_BINS	= git gitps gitview gitcmp gitkeys gitwipe
GIT_SCRIPTS	= gitmount gitaction gitredir gitrgrep gitxgrep .gitaction
GIT_RGREPS	= gitregrep gitrfgrep


all:	$(GIT_BINS)

installdirs:
	$(srcdir)/../mkinstalldirs $(bindir) $(libdir)

.c.o:
	$(CC) -c $(CFLAGS) $(DEFS) $<

git:	$(GIT_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(GIT_OBJS) $(LIBS)

gitps:	$(GITPS_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(GITPS_OBJS) $(LIBS)

gitview: $(GITVIEW_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITVIEW_OBJS) $(LIBS)

gitcmp:	$(GITCMP_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(GITCMP_OBJS) $(LIBS)

gitkeys: $(GITKEYS_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITKEYS_OBJS) $(LIBS)

gitwipe: $(GITWIPE_OBJS)
	 $(CC) $(LDFLAGS) -o $@ $(GITWIPE_OBJS) $(LIBS)

install: all install-only

install-only:
	for i in $(GIT_BINS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) $$i $(bindir)/$$i;\
	done
	for i in $(GIT_SCRIPTS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) $(srcdir)/$$i $(bindir)/$$i;\
	done
	for i in $(GIT_RGREPS);\
	do\
	    rm -f $(bindir)/$$i;\
	    ln $(bindir)/gitrgrep $(bindir)/$$i;\
	done

install-strip:
	for i in $(GIT_BINS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) -s $$i $(bindir)/$$i;\
	done
	for i in $(GIT_SCRIPTS);\
	do\
	    rm -f $(bindir)/$$i;\
	    $(INSTALL_PROGRAM) $(srcdir)/$$i $(bindir)/$$i;\
	done
	for i in $(GIT_RGREPS);\
	do\
	    rm -f $(bindir)/$$i;\
	    ln $(bindir)/gitrgrep $(bindir)/$$i;\
	done

dep:
	sed '/\#\#\# Dependencies/q' < Makefile.in > tmp_make
	(for i in *.c;\
	do\
	    $(CPP) -MM $$i;\
	done) >> tmp_make
	mv tmp_make Makefile.in

uninstall:
	-cd $(bindir) && rm -f $(GIT_BINS)
	-cd $(bindir) && rm -f $(GIT_SCRIPTS)
	-cd $(bindir) && rm -f $(GIT_RGREPS)

clean:
	-rm -f *.o *~ core* tutu* gogu* $(GIT_BINS)

mostlyclean: clean

distclean: clean
	-rm -f Makefile config.status config.log config.cache

realclean: distclean

tags:
	etags *.c *.h *.l *.y

etags:
	etags *.c *.h *.l *.y

### Dependencies
configure.o: configure.c file.h xstring.h stdc.h tty.h window.h \
 configure.h misc.h xtime.h
fnmatch.o: fnmatch.c fnmatch.h
fsusage.o: fsusage.c xio.h stat.h stdc.h fsusage.h
git.o: git.c file.h stdc.h xstring.h xmalloc.h xio.h stat.h tty.h \
 window.h inputline.h status.h panel.h xstack.h configure.h signals.h \
 system.h history.h tilde.h misc.h xtime.h
gitcmp.o: gitcmp.c file.h
gitkeys.o: gitkeys.c stdc.h xio.h stat.h
gitps.o: gitps.c file.h stdc.h xstring.h xmalloc.h tty.h window.h \
 configure.h tilde.h misc.h xtime.h
gitview.o: gitview.c file.h stdc.h xstring.h xmalloc.h xio.h stat.h \
 window.h configure.h tty.h misc.h xtime.h tilde.h
gitwipe.o: gitwipe.c xtime.h file.h
history.o: history.c file.h xio.h stat.h stdc.h xstring.h history.h \
 xmalloc.h
inputline.o: inputline.c xstring.h stdc.h xmalloc.h configure.h \
 history.h tty.h window.h inputline.h tilde.h misc.h xtime.h
misc.o: misc.c xstring.h stdc.h xmalloc.h configure.h file.h tty.h \
 window.h misc.h xtime.h
panel.o: panel.c file.h xtime.h stdc.h xstring.h xmalloc.h xio.h \
 stat.h xid.h fsusage.h window.h status.h signals.h tty.h inputline.h \
 panel.h xstack.h tilde.h fnmatch.h configure.h system.h misc.h
signals.o: signals.c signals.h stdc.h inputline.h window.h tty.h \
 misc.h xtime.h
status.o: status.c xtime.h xstring.h stdc.h xmalloc.h window.h \
 status.h configure.h tty.h misc.h
system.o: system.c xmalloc.h stdc.h xio.h stat.h tty.h window.h \
 signals.h inputline.h system.h misc.h xtime.h
tilde.o: tilde.c xmalloc.h stdc.h xstring.h tilde.h
tty.o: tty.c file.h stdc.h xstring.h xmalloc.h xio.h stat.h tty.h \
 window.h misc.h xtime.h
window.o: window.c window.h stdc.h xmalloc.h tty.h
xid.o: xid.c xstring.h stdc.h xmalloc.h xid.h
xio.o: xio.c xmalloc.h stdc.h xstring.h xio.h stat.h
xmalloc.o: xmalloc.c xmalloc.h stdc.h
xstack.o: xstack.c xmalloc.h stdc.h xstring.h xstack.h
xstring.o: xstring.c xmalloc.h stdc.h xstring.h
